/*
 * Copyright (C) 2010 mAPPn.Inc
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.mak.menoy;

import android.app.AlertDialog;
import android.app.TabActivity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewTreeObserver.OnPreDrawListener;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.TabHost;
import android.widget.TabHost.OnTabChangeListener;
import android.widget.TabHost.TabSpec;
import android.widget.TextView;

public class SoftTabActivity extends TabActivity implements OnTabChangeListener {
	// Tab id
	private static final String TAB_WEIDINGSOFT = "wendingsoft";
	private static final String TAB_NEWSOFT = "category";

	private TabHost mTabHost;
	private ImageView mMover;
	private int mStartX;
	private boolean mIsAnimationReady;
	

	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		setContentView(R.layout.soft_tab_main);
		
		initView();
		
		
	}
	
	

	@Override
	protected void onDestroy() {
		super.onDestroy();
		mIsAnimationReady = false;
	
	}
	

	

	private void initView() {

		mTabHost = (TabHost) this.findViewById(android.R.id.tabhost);
		mTabHost.setup();

		Intent i = new Intent(this, SoftWendingMainActivity.class);
		TabSpec tab1 = mTabHost
				.newTabSpec(TAB_WEIDINGSOFT)
				.setIndicator(
						createTabView(getApplicationContext(),
								getString(R.string.soft_tab_tuijian))).setContent(i);
		mTabHost.addTab(tab1);

		TabSpec tab2 = mTabHost
				.newTabSpec(TAB_WEIDINGSOFT)
				.setIndicator(
						createTabView(getApplicationContext(),
								getString(R.string.soft_tab_new)))
				.setContent(new Intent(this, SoftNewMainActivity.class));

		mTabHost.addTab(tab2);
		mTabHost.setCurrentTab(0);

		mTabHost.getViewTreeObserver().addOnPreDrawListener(
				new OnPreDrawListener() {
					@Override
					public boolean onPreDraw() {

						if (!mIsAnimationReady) {
							// initTabAnimationParameter();
						}
						return true;
					}
				});
		mTabHost.setOnTabChangedListener(this);
	}

	@Override
	public void onTabChanged(String tabId) {

	}

	
	private View createTabView(Context context, String text) {

		View view = LayoutInflater.from(context).inflate(
				R.layout.sot_tab_view, null);

		TextView textview = (TextView) view
				.findViewById(R.id.tab_widget_con);
		textview.setText(text);

		view.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
			}
		});
		return view;
	}
	

	

}
